from flask import current_app, jsonify, session, g
from info.utils.response_code import RET
from info.models import User
import functools
def do_index_class(index):
    if index == 0:
        return "first"
    elif index == 1:
        return "second"
    elif index == 2:
        return "third"
    return ""

def user_login_data(f):
    @functools.wraps(f)
    def wapper(*args,**kwargs):
        user_id = session.get('user_id', None)
        user = None
        if user_id:
            try:
                user = User.query.filter(User.id == user_id).first()
            except Exception as e:
                current_app.logger.error(e)
        g.user = user
        return f(*args,**kwargs)
    return wapper









